function hello() {
    $.ajax({
        url: "data1.json",
        success: function (data) {

            $.each(data.floor3, function (i) {
                if (getObjectValues(data.floor3[i])[0] == 1) {
                    $("#" + getObjectKeys(data.floor3[i])[0]).attr("class", "small-box bg-green");
                    $("#" + getObjectKeys(data.floor3[i])[0]).children("div").children("p").text("On");
                } else {
                    $("#" + getObjectKeys(data.floor3[i])[0]).attr("class", "small-box bg-gray");
                    $("#" + getObjectKeys(data.floor3[i])[0]).children("div").children("p").text("Off");
                }
            })


            $.each(data.floor2, function (i) {
                if (getObjectValues(data.floor2[i])[0] == 1) {
                    $("#" + getObjectKeys(data.floor2[i])[0]).attr("class", "small-box bg-green");
                    $("#" + getObjectKeys(data.floor2[i])[0]).children("div").children("p").text("On");
                } else {
                    $("#" + getObjectKeys(data.floor2[i])[0]).attr("class", "small-box bg-gray");
                    $("#" + getObjectKeys(data.floor2[i])[0]).children("div").children("p").text("Off");
                }
            })

        }
    });
}

function getObjectKeys(object) {
    var keys = [];
    for (var property in object)
        keys.push(property);
    return keys;
}

function getObjectValues(object) {
    var values = [];
    for (var property in object)
        values.push(object[property]);
    return values;
}

$(function () {
    $("#c3_1").knob();
    $("#c3_2").knob();
    $("#c3_3").knob();
    $("#c3_4").knob();
    $("#c3_5").knob();
    $("#c3_6").knob();
    $("#c3_7").knob();
    $("#c3_8").knob();
    $("#c3_9").knob();
    $("#c3_10").knob();
    $("#c2_1").knob();
    $("#c2_2").knob();
    $("#c2_3").knob();
    $("#c2_4").knob();
    $("#c2_5").knob();
    $("#c2_6").knob();
    $("#c2_7").knob();
    $("#c2_8").knob();
});

window.setInterval(hello, 10000);
